package Text_85;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Code {

	public static void main(String[] args) throws UnknownHostException {
		 //获取本机名称和IP地址
        InetAddress localHost = InetAddress.getLocalHost();
        System.out.println(localHost);
        //获取指定主机名的InetAddress对象
        InetAddress byName = InetAddress.getByName("DESKTOP-RCEF6TL");
        System.out.println(byName);
        //根据域名返回InetAddress对象
        InetAddress byName1 = InetAddress.getByName("www.baidu.com");
        System.out.println(byName1);
        //根据InetAddress对象返回IP地址
        String hostAddress = byName1.getHostAddress();
        System.out.println(hostAddress);


	}

}
